/*
 * Created on 10-Jul-06 Filename: PissOffCommand.java @author Daniel Yule
 */
package com.danicsoft.daide.command;

import com.danicsoft.daide.token.TokenMap.Commands;
import com.danicsoft.daide.token.TokenGroup;

/**
 * Implements the OFF command. From Eric Wald's <a
 * href="http://pydip.brainshell.org/docs/syntax.html">protocol specification</a>,
 * v0.14:
 * <h4><a name="OFF">server_message = OFF</a></h4>
 * <p>
 * This command is sent by the server, and indicates that the client should
 * exit. The client should exit without replying.
 * </p>
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public class PissOffCommand extends Command {

	/**
	 * Construct a new off command.
	 * @param tokens An empty <code>TokenGroup</code>
	 * @throws ParseException If it was not empty.
	 */
	public PissOffCommand(TokenGroup tokens) throws ParseException {
		super(tokens);
	}

	/**
	 * Constrcts a new off command for sending.
	 *
	 */
	public PissOffCommand() {
		super();
	}

	@Override
	public byte getType() {
		return Commands.OFF;
	}

	@Override
	public String toString() {
		return "Piss off";
	}

	public void doIO(TokenIO tokenIO, TokenGroup tokens) throws ParseException {
		if(tokenIO.doIfMore(tokens, false)) {
			throw new ParseException("Expcted an empty token group");
		}

	}

}
